﻿<%@ Page Title="Quản lý đơn hàng" Language="C#" MasterPageFile="~/OneColumn.Master" AutoEventWireup="true" CodeBehind="OrderManagement.aspx.cs" Inherits="KCL.Management.OrderManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PageTitle" runat="server">
	Quản lý đơn hàng
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PageHeader" runat="server">
	<link type="text/css" href="../styles/themes/base/jquery.ui.all.css" rel="stylesheet" />
	<script type="text/javascript" src="../styles/ui/jquery.ui.core.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.position.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.mouse.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.draggable.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.dialog.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.button.js"></script>
	<script type="text/javascript" src="../styles/external/jquery.bgiframe-2.1.2.js"></script>
	<script type="text/javascript">
		$(document).ready(function () {
			$("#divCreateOrder").dialog({
				autoOpen: false,
				modal: true,
				width: 500,
				height: 'auto',
				maxHeight: 900,
				title: 'Nhập thông tin khách hàng',
				resizable: false
			});
			$("#btnSave").button();
		});
		function SubmitOrder() {
			$.ajax({
				url: "Order.ashx?",
				type: "POST",
				dataType: "script",
				data: {
					name: $("#OrderName").val(),
					address: $("#address").val(),
					contactAddress: $("#contactAddress").val(),
					contactPerson: $("#contactPerson").val(),
					phone: $("#phone").val(),
					mobile: $("#mobile").val(),
					fax: $("#fax").val(),
					accountNumber: $("#accountNumber").val(),
					bank: $("#bank").val(),
					taxNumber: $("#taxNumber").val(),
					director: $("#director").val(),
					id: $("#OrderId").val(),
					action: $("#action").val()
				}
			});
		}
		function DisplayOrder(id) {
			var currentRow = $("#link" + id).parent().parent().children();
			$("#OrderName").val($(currentRow[0]).html());
			$("#address").val($(currentRow[1]).html());
			$("#contactAddress").val($(currentRow[2]).html());
			$("#contactPerson").val($(currentRow[3]).html());
			$("#phone").val($(currentRow[4]).html());
			$("#mobile").val($(currentRow[5]).html());
			$("#fax").val($(currentRow[6]).html());
			$("#accountNumber").val($(currentRow[7]).html());
			$("#bank").val($(currentRow[8]).html());
			$("#taxNumber").val($(currentRow[9]).html());
			$("#director").val($(currentRow[10]).html());
			$("#action").val("edit");
			$("#OrderId").val(id);
			$("#divCreateOrder").dialog("open");
		}
		function RefreshOrder(id) {
			var currentRow = $("#link" + id).parent().parent().children();
			$(currentRow[0]).html($("#OrderName").val());
			$(currentRow[1]).html($("#address").val());
			$(currentRow[2]).html($("#contactAddress").val());
			$(currentRow[3]).html($("#contactPerson").val());
			$(currentRow[4]).html($("#phone").val());
			$(currentRow[5]).html($("#mobile").val());
			$(currentRow[6]).html($("#fax").val());
			$(currentRow[7]).html($("#accountNumber").val());
			$(currentRow[8]).html($("#bank").val());
			$(currentRow[9]).html($("#taxNumber").val());
			$(currentRow[10]).html($("#director").val());
		}
	</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
	<asp:ObjectDataSource ID="dsOrder" TypeName="KCL.Code.Data.OrderDAO" SortParameterName="sortExpression" SelectMethod="GetOrders" SelectCountMethod="GetTotalOrder" EnablePaging="true" runat="server">
		<SelectParameters>
			<asp:FormParameter ConvertEmptyStringToNull="true" FormField="" Name="fromDate" Type="String" />
			<asp:FormParameter Name="isFinished" Type="Boolean" />
		</SelectParameters>
	</asp:ObjectDataSource>
	<h2>Danh sách những đơn hàng chưa hoàn thành</h2>
	<asp:GridView ID="gvOrder" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false" BackColor="Wheat" BorderColor="Firebrick" BorderStyle="Ridge" BorderWidth="1px" CellPadding="7" DataSourceID="dsOrder" GridLines="None" Width="100%" runat="server">
		<HeaderStyle BackColor="Black" ForeColor="Azure" Font-Bold="true" Wrap="false"/>
		<FooterStyle ForeColor="Maroon" BackColor="DarkGoldenrod" />
		<PagerStyle ForeColor="Snow" HorizontalAlign="Right" BackColor="SaddleBrown" />
		<RowStyle BackColor="Ivory" />
		<Columns>
			<asp:BoundField HeaderText="Mã ĐH" DataField="code" SortExpression="code" />
			<asp:BoundField HeaderText="Tên khách hàng" DataField="customerName" />
			<asp:BoundField HeaderText="Ngày đặt hàng" DataField="createdDate" SortExpression="createdDate" />
			<asp:BoundField HeaderText="Ngày giao hàng" DataField="deliveryDate" SortExpression="deliveryDate" />
			<asp:BoundField HeaderText="Tổng tiền" DataField="totalPrice" SortExpression="totalPrice" />
			<asp:TemplateField HeaderText="Quản lý">
				<ItemTemplate>
					<a href="../Input/inputFinishedProduct.aspx?orderId=<%# Eval("id")%>"><img src="../styles/images/inputFinishedProduct.png" alt="Nhập thành phẩm" style="border:0;width:16px;" /></a>
				</ItemTemplate>
			</asp:TemplateField>
		</Columns>
		<AlternatingRowStyle BackColor="SeaShell" />
	</asp:GridView>
	<i>Đang xem trang <%=gvOrder.PageIndex + 1%> / <%=gvOrder.PageCount %></i>
	<div id="divCreateOrder">
		<table border="0" cellpadding="4px" cellspacing="0px">
			<tr><td>Tên cty</td><td><input type="text" id="OrderName" /></td></tr>
			<tr><td>Địa chỉ</td><td><input type="text" id="address" /></td></tr>
			<tr><td>Địa chỉ liên hệ</td><td><input type="text" id="contactAddress" /></td></tr>
			<tr><td>Người liên hệ</td><td><input type="text" id="contactPerson" /></td></tr>
			<tr><td>Số đt</td><td><input type="text" id="phone" /></td></tr>
			<tr><td>Mobile</td><td><input type="text" id="mobile" /></td></tr>
			<tr><td>Fax</td><td><input type="text" id="fax" /></td></tr>
			<tr><td>Số tài khoản</td><td><input type="text" id="accountNumber" /></td></tr>
			<tr><td>Ngân hàng</td><td><input type="text" id="bank" /></td></tr>
			<tr><td>Mã số thuế</td><td><input type="text" id="taxNumber" /></td></tr>
			<tr><td>Giám đốc</td><td><input type="text" id="director" /></td></tr>
		</table>
		<p />
		<input type="button" id="btnSave" value="&nbsp;Lưu&nbsp;" onclick="SubmitOrder()" style="text-align: center" />
		<input type="hidden" value="create" id="action" />
		<input type="hidden" value="-1" id="OrderId" />
	</div>
</asp:Content>